package com.run_java_test.test6;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("dynamic")
public class TestGet {
    @Autowired
    private RequestMappingHandlerMapping requestMappingHandlerMapping;

    // 查看所有路由
    @RequestMapping("/routes")
    public List<String> getRoutes() {
        return requestMappingHandlerMapping.getHandlerMethods().keySet().stream()
                .map(RequestMappingInfo::toString)
                .collect(Collectors.toList());
    }
}
